﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using Ue.Framework.Data;
using Ue.Infrastructure.EntityFactoryFramework;
using Ue.Qcdz.Domain.Medias;
using Ue.Qcdz.Domain.Tags;

namespace Ue.Qcdz.Repositories.Medias
{
    internal class MediaFactory : IEntityFactory<TheMedia>
    {
        internal class FieldNames : FieldNamesBase
        {
            public const string MediaName = "Name";
            public const string MediaImage = "imgUrl";
            public const string MediaLink = "link";
            public const string MediaType = "typeId";
            public class TagFiledNames
            {
                public const string TagName = "Name";
            }
        }
        #region Implementation of IEntityFactory<TheMedia>

        public TheMedia BuildEntity(IDataReader reader)
        {
            
            return new TheMedia(
                reader.Get<string>(FieldNames.MediaName),
                reader.Get<string>(FieldNames.MediaImage),
                reader.Get<string>(FieldNames.MediaLink),
                reader.Get<Guid>(FieldNames.EntityKey)
                );
        }

        #endregion
    }
}
